﻿using UnityEngine;

[RequireComponent (typeof (Rigidbody2D), typeof (Animator))]
public class Spaceship : MonoBehaviour {
	// 移动速度
	public float speed;

	// 攻击间隔
	public float shotDelay;

	// 子弹预制件对象
	public GameObject[] bulletList;

	// 能否射击
	public bool canShot;

	// 爆炸特效
	public GameObject explosion;

	// 动画控制
	protected Animator animator;

	void Start () {
		// 获取动画组件
		animator = GetComponent<Animator> ();
	}

	// 生成爆炸组件
	public void Explosion () {
		Instantiate (explosion, transform.position, transform.rotation);
	}

	// 生成子弹
	public virtual void Shot (Transform origin) {

		// 多种
		foreach (var b in bulletList) {
			Instantiate (b, origin.position, origin.rotation);
		}
	}

	// 外部获取动画
	public Animator GetAnimator () {
		return animator;
	}
}